define(function(require,exports,module){
	
			var rulesVaild = ["sendName","sendPhone","receiveName","receivePhone","receiveAddress","remark"];
			$("#cardSendForm").validate({
				rules:{
					sendName:{
						required: true,
						rangelength:[2,32]
					},
					sendPhone:{
						required: true,
						isMobile:true
					},					
					receiveName:{
						required: true,
						rangelength:[2,32]
					},
					receivePhone:{
						required: true,
						isMobile:true
					},
					receiveAddress:{
						required: true,
						rangelength:[5,50]
					},
					remark:{
						required: true,
						maxlength:200
					}
				},
				messages:{
					sendName:{
						required: "请输入发送人姓名",
						rangelength: "发送人姓名长度不正确"
					},
					sendPhone:{
						required:"请输入发送人手机号码",
						isMobile:"发送人手机号码格式错误"
					},
					receiveName:{
						required: "请输入收件人姓名",
						rangelength: "收件人姓名长度不正确"
					},
					receivePhone:{
						required:"请输入收件人手机号码",
						isMobile:"收件人手机号码格式错误"
					},
					receiveAddress:{
						required: "请输入收件人地址",
						rangelength:"请正确输入收件人地址"
					},
					remark:{
						required: "请输入祝福语",
						maxlength:"祝福语最大长度不能超过200"
					}
				},
				showErrors:function(errorMap, errorList){
			 		
			 		//$("#showErrorTip").css("display","none");
			 		$("#showErrorTip").text("");
			 		
			 		for(var i=0,len=rulesVaild.length;i<len;i++){
			 			if(errorMap[rulesVaild[i]]!=undefined){
				 			//$("#showErrorTip").css("display","block");
					 		$("#showErrorTip").text(errorMap[rulesVaild[i]]);
				 		}
			 		}
			 		
			 		if(errorMap["sendName"]){
			 			$("#showErrorTip").css("display","block");
				 		$("#showErrorTip").text(errorMap["sendName"]);
			 		}
			 		
			 	},
			    submitHandler:function(form){
			    }  
			});


			$("#sendCard").click(function(){
				if($("#cardSendForm").valid()==true){
					$("#cardSendForm").ajaxSubmit(function(data) {
						var result = data.resCode;
						if (result == 1) {
							
							
							window.location.href = "/mobile/cardsendsuccess.html";				
						} else {
							layer.alert(data.resMsg);
							
						}
					});
				}
			});

	 
});

